{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "fc84d853",
   "metadata": {},
   "source": [
    "### 决策树分裂【gini系数】"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "e2e42266",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2022-06-27T12:51:18.313869Z",
     "start_time": "2022-06-27T12:51:17.854932Z"
    },
    "collapsed": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['N' 'Y' 'Y' 'Y' 'Y' 'Y' 'N' 'Y' 'Y' 'N']\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>日志密度</th>\n",
       "      <th>好友密度</th>\n",
       "      <th>真实头像</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   日志密度  好友密度  真实头像\n",
       "0     0     0     0\n",
       "1     0     2     1\n",
       "2     2     1     1\n",
       "3     1     1     1\n",
       "4     2     1     1\n",
       "5     1     2     0\n",
       "6     1     0     1\n",
       "7     2     1     1\n",
       "8     1     0     1\n",
       "9     0     0     1"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import numpy as np\n",
    "import pandas as pd\n",
    "y = np.array(list('NYYYYYNYYN'))\n",
    "print(y)\n",
    "X = pd.DataFrame({'日志密度':list('sslmlmmlms'),\n",
    "                  '好友密度':list('slmmmlsmss'),\n",
    "                  '真实头像':list('NYYYYNYYYY')})\n",
    "X['日志密度'] = X['日志密度'].map({'s':0,'m':1,'l':2})\n",
    "X['好友密度'] = X['好友密度'].map({'s':0,'m':1,'l':2})\n",
    "X['真实头像'] = X['真实头像'].map({'N':0,'Y':1})\n",
    "X"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "1b4bb672",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2022-06-27T12:53:19.594514Z",
     "start_time": "2022-06-27T12:53:19.368222Z"
    },
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "image/svg+xml": [
       "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n",
       "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n",
       " \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n",
       "<!-- Generated by graphviz version 2.48.0 (20210717.1556)\n",
       " -->\n",
       "<!-- Title: Tree Pages: 1 -->\n",
       "<svg width=\"291pt\" height=\"314pt\"\n",
       " viewBox=\"0.00 0.00 291.00 314.00\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n",
       "<g id=\"graph0\" class=\"graph\" transform=\"scale(1 1) rotate(0) translate(4 310)\">\n",
       "<title>Tree</title>\n",
       "<polygon fill=\"white\" stroke=\"transparent\" points=\"-4,4 -4,-310 287,-310 287,4 -4,4\"/>\n",
       "<!-- 0 -->\n",
       "<g id=\"node1\" class=\"node\">\n",
       "<title>0</title>\n",
       "<path fill=\"#8ec7f0\" stroke=\"black\" d=\"M219.5,-306C219.5,-306 119.5,-306 119.5,-306 113.5,-306 107.5,-300 107.5,-294 107.5,-294 107.5,-235 107.5,-235 107.5,-229 113.5,-223 119.5,-223 119.5,-223 219.5,-223 219.5,-223 225.5,-223 231.5,-229 231.5,-235 231.5,-235 231.5,-294 231.5,-294 231.5,-300 225.5,-306 219.5,-306\"/>\n",
       "<text text-anchor=\"middle\" x=\"169.5\" y=\"-290.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">好友密度 &lt;= 0.5</text>\n",
       "<text text-anchor=\"middle\" x=\"169.5\" y=\"-275.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">gini = 0.42</text>\n",
       "<text text-anchor=\"middle\" x=\"169.5\" y=\"-260.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 10</text>\n",
       "<text text-anchor=\"middle\" x=\"169.5\" y=\"-245.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [3, 7]</text>\n",
       "<text text-anchor=\"middle\" x=\"169.5\" y=\"-230.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = Y</text>\n",
       "</g>\n",
       "<!-- 1 -->\n",
       "<g id=\"node2\" class=\"node\">\n",
       "<title>1</title>\n",
       "<path fill=\"#eeab7b\" stroke=\"black\" d=\"M155.5,-187C155.5,-187 55.5,-187 55.5,-187 49.5,-187 43.5,-181 43.5,-175 43.5,-175 43.5,-116 43.5,-116 43.5,-110 49.5,-104 55.5,-104 55.5,-104 155.5,-104 155.5,-104 161.5,-104 167.5,-110 167.5,-116 167.5,-116 167.5,-175 167.5,-175 167.5,-181 161.5,-187 155.5,-187\"/>\n",
       "<text text-anchor=\"middle\" x=\"105.5\" y=\"-171.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">日志密度 &lt;= 0.5</text>\n",
       "<text text-anchor=\"middle\" x=\"105.5\" y=\"-156.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">gini = 0.375</text>\n",
       "<text text-anchor=\"middle\" x=\"105.5\" y=\"-141.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 4</text>\n",
       "<text text-anchor=\"middle\" x=\"105.5\" y=\"-126.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [3, 1]</text>\n",
       "<text text-anchor=\"middle\" x=\"105.5\" y=\"-111.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = N</text>\n",
       "</g>\n",
       "<!-- 0&#45;&gt;1 -->\n",
       "<g id=\"edge1\" class=\"edge\">\n",
       "<title>0&#45;&gt;1</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M147.3,-222.91C142.53,-214.2 137.44,-204.9 132.52,-195.89\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"135.53,-194.11 127.67,-187.02 129.39,-197.47 135.53,-194.11\"/>\n",
       "<text text-anchor=\"middle\" x=\"120.64\" y=\"-207.31\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">True</text>\n",
       "</g>\n",
       "<!-- 4 -->\n",
       "<g id=\"node5\" class=\"node\">\n",
       "<title>4</title>\n",
       "<path fill=\"#399de5\" stroke=\"black\" d=\"M271,-179.5C271,-179.5 198,-179.5 198,-179.5 192,-179.5 186,-173.5 186,-167.5 186,-167.5 186,-123.5 186,-123.5 186,-117.5 192,-111.5 198,-111.5 198,-111.5 271,-111.5 271,-111.5 277,-111.5 283,-117.5 283,-123.5 283,-123.5 283,-167.5 283,-167.5 283,-173.5 277,-179.5 271,-179.5\"/>\n",
       "<text text-anchor=\"middle\" x=\"234.5\" y=\"-164.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">gini = 0.0</text>\n",
       "<text text-anchor=\"middle\" x=\"234.5\" y=\"-149.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 6</text>\n",
       "<text text-anchor=\"middle\" x=\"234.5\" y=\"-134.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [0, 6]</text>\n",
       "<text text-anchor=\"middle\" x=\"234.5\" y=\"-119.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = Y</text>\n",
       "</g>\n",
       "<!-- 0&#45;&gt;4 -->\n",
       "<g id=\"edge4\" class=\"edge\">\n",
       "<title>0&#45;&gt;4</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M192.05,-222.91C198.24,-211.76 204.97,-199.66 211.2,-188.44\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"214.28,-190.11 216.07,-179.67 208.16,-186.71 214.28,-190.11\"/>\n",
       "<text text-anchor=\"middle\" x=\"222.94\" y=\"-200.01\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">False</text>\n",
       "</g>\n",
       "<!-- 2 -->\n",
       "<g id=\"node3\" class=\"node\">\n",
       "<title>2</title>\n",
       "<path fill=\"#e58139\" stroke=\"black\" d=\"M85,-68C85,-68 12,-68 12,-68 6,-68 0,-62 0,-56 0,-56 0,-12 0,-12 0,-6 6,0 12,0 12,0 85,0 85,0 91,0 97,-6 97,-12 97,-12 97,-56 97,-56 97,-62 91,-68 85,-68\"/>\n",
       "<text text-anchor=\"middle\" x=\"48.5\" y=\"-52.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">gini = 0.0</text>\n",
       "<text text-anchor=\"middle\" x=\"48.5\" y=\"-37.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 2</text>\n",
       "<text text-anchor=\"middle\" x=\"48.5\" y=\"-22.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [2, 0]</text>\n",
       "<text text-anchor=\"middle\" x=\"48.5\" y=\"-7.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = N</text>\n",
       "</g>\n",
       "<!-- 1&#45;&gt;2 -->\n",
       "<g id=\"edge2\" class=\"edge\">\n",
       "<title>1&#45;&gt;2</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M84.28,-103.73C79.76,-95.06 74.99,-85.9 70.46,-77.18\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"73.56,-75.55 65.83,-68.3 67.35,-78.79 73.56,-75.55\"/>\n",
       "</g>\n",
       "<!-- 3 -->\n",
       "<g id=\"node4\" class=\"node\">\n",
       "<title>3</title>\n",
       "<path fill=\"#ffffff\" stroke=\"black\" d=\"M200,-68C200,-68 127,-68 127,-68 121,-68 115,-62 115,-56 115,-56 115,-12 115,-12 115,-6 121,0 127,0 127,0 200,0 200,0 206,0 212,-6 212,-12 212,-12 212,-56 212,-56 212,-62 206,-68 200,-68\"/>\n",
       "<text text-anchor=\"middle\" x=\"163.5\" y=\"-52.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">gini = 0.5</text>\n",
       "<text text-anchor=\"middle\" x=\"163.5\" y=\"-37.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 2</text>\n",
       "<text text-anchor=\"middle\" x=\"163.5\" y=\"-22.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [1, 1]</text>\n",
       "<text text-anchor=\"middle\" x=\"163.5\" y=\"-7.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = N</text>\n",
       "</g>\n",
       "<!-- 1&#45;&gt;3 -->\n",
       "<g id=\"edge3\" class=\"edge\">\n",
       "<title>1&#45;&gt;3</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M127.1,-103.73C131.69,-95.06 136.54,-85.9 141.16,-77.18\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"144.27,-78.77 145.86,-68.3 138.09,-75.5 144.27,-78.77\"/>\n",
       "</g>\n",
       "</g>\n",
       "</svg>\n"
      ],
      "text/plain": [
       "<graphviz.sources.Source at 0x27ad2e76730>"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from sklearn.datasets import load_iris\n",
    "from sklearn.tree import DecisionTreeClassifier\n",
    "import graphviz # 第三方库，pip install graghviz\n",
    "# 这个库，有一些依赖：\n",
    "from sklearn import tree\n",
    "model = DecisionTreeClassifier(criterion='gini')\n",
    "model.fit(X,y)\n",
    "# 图片数据\n",
    "dot_data = tree.export_graphviz(model, out_file=None, \n",
    "                            feature_names= X.columns,# 特征名\n",
    "                            class_names=np.unique(y),# 类别名\n",
    "                            filled=True, # 填充颜色\n",
    "                            rounded=True) # 圆角\n",
    "\n",
    "graph = graphviz.Source(dot_data)\n",
    "graph"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "32bd3414",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2022-06-27T13:04:20.716938Z",
     "start_time": "2022-06-27T13:04:20.707962Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.15000000000000002"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "0.375 * 0.4"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "c3f09df9",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2022-06-27T12:55:32.740781Z",
     "start_time": "2022-06-27T12:55:32.722763Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.42"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "p = pd.Series(y).value_counts()/len(y)\n",
    "round((p * (1-p)).sum(),2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "7a95f743",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2022-06-27T13:03:07.156203Z",
     "start_time": "2022-06-27T13:03:07.137451Z"
    },
    "collapsed": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>日志密度</th>\n",
       "      <th>好友密度</th>\n",
       "      <th>真实头像</th>\n",
       "      <th>真实用户</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>N</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>Y</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>Y</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>Y</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>Y</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>0</td>\n",
       "      <td>Y</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>N</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>Y</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>Y</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>N</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   日志密度  好友密度  真实头像 真实用户\n",
       "0     0     0     0    N\n",
       "1     0     2     1    Y\n",
       "2     2     1     1    Y\n",
       "3     1     1     1    Y\n",
       "4     2     1     1    Y\n",
       "5     1     2     0    Y\n",
       "6     1     0     1    N\n",
       "7     2     1     1    Y\n",
       "8     1     0     1    Y\n",
       "9     0     0     1    N"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "X['真实用户'] = y # 数据合并\n",
    "X"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "8c39efa3",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2022-06-27T13:05:18.700594Z",
     "start_time": "2022-06-27T13:05:18.659713Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "日志密度 0.5 0.3047619047619048\n",
      "日志密度 1.5 0.3428571428571428\n",
      "好友密度 0.5 0.15000000000000002\n",
      "好友密度 1.5 0.375\n",
      "真实头像 0.5 0.4\n",
      "最佳裂分条件是： {'好友密度': 0.5}\n"
     ]
    }
   ],
   "source": [
    "columns = ['日志密度','好友密度','真实头像']\n",
    "lower_gini = 1 # 记录，最低信息熵，是多少\n",
    "condition = {} # 记录最佳裂分点\n",
    "for col in columns:\n",
    "    x = X[col].unique()\n",
    "    x.sort()\n",
    "    # 如何划分问题\n",
    "    for i in range(len(x) -1):\n",
    "        split = x[i:i+2].mean()\n",
    "        cond = X[col] <= split\n",
    "        p = cond.value_counts()/cond.size\n",
    "        indexes = p.index\n",
    "        gini = 0\n",
    "        for index in indexes:\n",
    "            user = X[cond == index]['真实用户']\n",
    "            p_user = user.value_counts()/user.size\n",
    "            gini += (p_user * (1-p_user)).sum() * p[index]\n",
    "        print(col,split,gini)\n",
    "        if gini < lower_gini:\n",
    "            condition.clear()\n",
    "            lower_gini = gini\n",
    "            condition[col] = split\n",
    "print('最佳裂分条件是：',condition)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "bdd796ef",
   "metadata": {},
   "source": [
    "### 决策树实战"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1821f681",
   "metadata": {},
   "source": [
    "#### 决策树分类鸢尾花数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "123a664b",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2022-06-27T13:29:38.901884Z",
     "start_time": "2022-06-27T13:29:38.327271Z"
    },
    "collapsed": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "真实类别是： [0 2 1 0 2 1 0 1 1 1 2 2 2 0 0 1 2 1 0 2 1 0 1 1 2 0 0 1 0 0 2 0 2 2 1 2 0\n",
      " 0]\n",
      "算法预测是： [0 2 1 0 2 1 0 1 1 1 2 2 2 0 0 1 2 1 0 2 1 0 1 1 2 0 0 1 0 0 2 0 1 2 1 2 0\n",
      " 0]\n",
      "准确率是： 0.9736842105263158\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "array([[1., 0., 0.],\n",
       "       [0., 0., 1.],\n",
       "       [0., 1., 0.],\n",
       "       [1., 0., 0.],\n",
       "       [0., 0., 1.],\n",
       "       [0., 1., 0.],\n",
       "       [1., 0., 0.],\n",
       "       [0., 1., 0.],\n",
       "       [0., 1., 0.],\n",
       "       [0., 1., 0.],\n",
       "       [0., 0., 1.],\n",
       "       [0., 0., 1.],\n",
       "       [0., 0., 1.],\n",
       "       [1., 0., 0.],\n",
       "       [1., 0., 0.],\n",
       "       [0., 1., 0.],\n",
       "       [0., 0., 1.],\n",
       "       [0., 1., 0.],\n",
       "       [1., 0., 0.],\n",
       "       [0., 0., 1.],\n",
       "       [0., 1., 0.],\n",
       "       [1., 0., 0.],\n",
       "       [0., 1., 0.],\n",
       "       [0., 1., 0.],\n",
       "       [0., 0., 1.],\n",
       "       [1., 0., 0.],\n",
       "       [1., 0., 0.],\n",
       "       [0., 1., 0.],\n",
       "       [1., 0., 0.],\n",
       "       [1., 0., 0.],\n",
       "       [0., 0., 1.],\n",
       "       [1., 0., 0.],\n",
       "       [0., 1., 0.],\n",
       "       [0., 0., 1.],\n",
       "       [0., 1., 0.],\n",
       "       [0., 0., 1.],\n",
       "       [1., 0., 0.],\n",
       "       [1., 0., 0.]])"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import numpy as np\n",
    "from sklearn.tree import DecisionTreeClassifier\n",
    "from sklearn import datasets\n",
    "from sklearn.model_selection import train_test_split\n",
    "from sklearn import tree\n",
    "import matplotlib.pyplot as plt\n",
    "\n",
    "iris = datasets.load_iris() # 字典类型的数据\n",
    "X = iris['data']\n",
    "y = iris['target']\n",
    "name = iris['target_names'] # 特征，画图时使用\n",
    "\n",
    "# 随机拆分\n",
    "X_train,X_test,y_train,y_test = train_test_split(X,y,random_state = 256)\n",
    "\n",
    "# max_depth调整树深度：剪枝操作\n",
    "# max_depth默认，深度最大，延伸到将数据完全划分开为止。\n",
    "model = DecisionTreeClassifier(max_depth=None,criterion='entropy')\n",
    "model.fit(X_train,y_train)\n",
    "\n",
    "y_ = model.predict(X_test) # 将数据X_test放到，决策树中，特征条件，沿着某个分支，走走走，到叶节点\n",
    "# 叶节点，是什么类别，这个数据，就判定为什么类别！！！\n",
    "\n",
    "print('真实类别是：',y_test)\n",
    "print('算法预测是：',y_)\n",
    "print('准确率是：',model.score(X_test,y_test))\n",
    "\n",
    "# 决策树提供了predict_proba这个方法，发现这个方法，返回值要么是0，要么是1\n",
    "model.predict_proba(X_test)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "19966845",
   "metadata": {},
   "source": [
    "#### 决策树可视化"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "103d2583",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2022-06-27T13:35:25.963864Z",
     "start_time": "2022-06-27T13:35:25.944855Z"
    },
    "collapsed": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'data': array([[5.1, 3.5, 1.4, 0.2],\n",
       "        [4.9, 3. , 1.4, 0.2],\n",
       "        [4.7, 3.2, 1.3, 0.2],\n",
       "        [4.6, 3.1, 1.5, 0.2],\n",
       "        [5. , 3.6, 1.4, 0.2],\n",
       "        [5.4, 3.9, 1.7, 0.4],\n",
       "        [4.6, 3.4, 1.4, 0.3],\n",
       "        [5. , 3.4, 1.5, 0.2],\n",
       "        [4.4, 2.9, 1.4, 0.2],\n",
       "        [4.9, 3.1, 1.5, 0.1],\n",
       "        [5.4, 3.7, 1.5, 0.2],\n",
       "        [4.8, 3.4, 1.6, 0.2],\n",
       "        [4.8, 3. , 1.4, 0.1],\n",
       "        [4.3, 3. , 1.1, 0.1],\n",
       "        [5.8, 4. , 1.2, 0.2],\n",
       "        [5.7, 4.4, 1.5, 0.4],\n",
       "        [5.4, 3.9, 1.3, 0.4],\n",
       "        [5.1, 3.5, 1.4, 0.3],\n",
       "        [5.7, 3.8, 1.7, 0.3],\n",
       "        [5.1, 3.8, 1.5, 0.3],\n",
       "        [5.4, 3.4, 1.7, 0.2],\n",
       "        [5.1, 3.7, 1.5, 0.4],\n",
       "        [4.6, 3.6, 1. , 0.2],\n",
       "        [5.1, 3.3, 1.7, 0.5],\n",
       "        [4.8, 3.4, 1.9, 0.2],\n",
       "        [5. , 3. , 1.6, 0.2],\n",
       "        [5. , 3.4, 1.6, 0.4],\n",
       "        [5.2, 3.5, 1.5, 0.2],\n",
       "        [5.2, 3.4, 1.4, 0.2],\n",
       "        [4.7, 3.2, 1.6, 0.2],\n",
       "        [4.8, 3.1, 1.6, 0.2],\n",
       "        [5.4, 3.4, 1.5, 0.4],\n",
       "        [5.2, 4.1, 1.5, 0.1],\n",
       "        [5.5, 4.2, 1.4, 0.2],\n",
       "        [4.9, 3.1, 1.5, 0.2],\n",
       "        [5. , 3.2, 1.2, 0.2],\n",
       "        [5.5, 3.5, 1.3, 0.2],\n",
       "        [4.9, 3.6, 1.4, 0.1],\n",
       "        [4.4, 3. , 1.3, 0.2],\n",
       "        [5.1, 3.4, 1.5, 0.2],\n",
       "        [5. , 3.5, 1.3, 0.3],\n",
       "        [4.5, 2.3, 1.3, 0.3],\n",
       "        [4.4, 3.2, 1.3, 0.2],\n",
       "        [5. , 3.5, 1.6, 0.6],\n",
       "        [5.1, 3.8, 1.9, 0.4],\n",
       "        [4.8, 3. , 1.4, 0.3],\n",
       "        [5.1, 3.8, 1.6, 0.2],\n",
       "        [4.6, 3.2, 1.4, 0.2],\n",
       "        [5.3, 3.7, 1.5, 0.2],\n",
       "        [5. , 3.3, 1.4, 0.2],\n",
       "        [7. , 3.2, 4.7, 1.4],\n",
       "        [6.4, 3.2, 4.5, 1.5],\n",
       "        [6.9, 3.1, 4.9, 1.5],\n",
       "        [5.5, 2.3, 4. , 1.3],\n",
       "        [6.5, 2.8, 4.6, 1.5],\n",
       "        [5.7, 2.8, 4.5, 1.3],\n",
       "        [6.3, 3.3, 4.7, 1.6],\n",
       "        [4.9, 2.4, 3.3, 1. ],\n",
       "        [6.6, 2.9, 4.6, 1.3],\n",
       "        [5.2, 2.7, 3.9, 1.4],\n",
       "        [5. , 2. , 3.5, 1. ],\n",
       "        [5.9, 3. , 4.2, 1.5],\n",
       "        [6. , 2.2, 4. , 1. ],\n",
       "        [6.1, 2.9, 4.7, 1.4],\n",
       "        [5.6, 2.9, 3.6, 1.3],\n",
       "        [6.7, 3.1, 4.4, 1.4],\n",
       "        [5.6, 3. , 4.5, 1.5],\n",
       "        [5.8, 2.7, 4.1, 1. ],\n",
       "        [6.2, 2.2, 4.5, 1.5],\n",
       "        [5.6, 2.5, 3.9, 1.1],\n",
       "        [5.9, 3.2, 4.8, 1.8],\n",
       "        [6.1, 2.8, 4. , 1.3],\n",
       "        [6.3, 2.5, 4.9, 1.5],\n",
       "        [6.1, 2.8, 4.7, 1.2],\n",
       "        [6.4, 2.9, 4.3, 1.3],\n",
       "        [6.6, 3. , 4.4, 1.4],\n",
       "        [6.8, 2.8, 4.8, 1.4],\n",
       "        [6.7, 3. , 5. , 1.7],\n",
       "        [6. , 2.9, 4.5, 1.5],\n",
       "        [5.7, 2.6, 3.5, 1. ],\n",
       "        [5.5, 2.4, 3.8, 1.1],\n",
       "        [5.5, 2.4, 3.7, 1. ],\n",
       "        [5.8, 2.7, 3.9, 1.2],\n",
       "        [6. , 2.7, 5.1, 1.6],\n",
       "        [5.4, 3. , 4.5, 1.5],\n",
       "        [6. , 3.4, 4.5, 1.6],\n",
       "        [6.7, 3.1, 4.7, 1.5],\n",
       "        [6.3, 2.3, 4.4, 1.3],\n",
       "        [5.6, 3. , 4.1, 1.3],\n",
       "        [5.5, 2.5, 4. , 1.3],\n",
       "        [5.5, 2.6, 4.4, 1.2],\n",
       "        [6.1, 3. , 4.6, 1.4],\n",
       "        [5.8, 2.6, 4. , 1.2],\n",
       "        [5. , 2.3, 3.3, 1. ],\n",
       "        [5.6, 2.7, 4.2, 1.3],\n",
       "        [5.7, 3. , 4.2, 1.2],\n",
       "        [5.7, 2.9, 4.2, 1.3],\n",
       "        [6.2, 2.9, 4.3, 1.3],\n",
       "        [5.1, 2.5, 3. , 1.1],\n",
       "        [5.7, 2.8, 4.1, 1.3],\n",
       "        [6.3, 3.3, 6. , 2.5],\n",
       "        [5.8, 2.7, 5.1, 1.9],\n",
       "        [7.1, 3. , 5.9, 2.1],\n",
       "        [6.3, 2.9, 5.6, 1.8],\n",
       "        [6.5, 3. , 5.8, 2.2],\n",
       "        [7.6, 3. , 6.6, 2.1],\n",
       "        [4.9, 2.5, 4.5, 1.7],\n",
       "        [7.3, 2.9, 6.3, 1.8],\n",
       "        [6.7, 2.5, 5.8, 1.8],\n",
       "        [7.2, 3.6, 6.1, 2.5],\n",
       "        [6.5, 3.2, 5.1, 2. ],\n",
       "        [6.4, 2.7, 5.3, 1.9],\n",
       "        [6.8, 3. , 5.5, 2.1],\n",
       "        [5.7, 2.5, 5. , 2. ],\n",
       "        [5.8, 2.8, 5.1, 2.4],\n",
       "        [6.4, 3.2, 5.3, 2.3],\n",
       "        [6.5, 3. , 5.5, 1.8],\n",
       "        [7.7, 3.8, 6.7, 2.2],\n",
       "        [7.7, 2.6, 6.9, 2.3],\n",
       "        [6. , 2.2, 5. , 1.5],\n",
       "        [6.9, 3.2, 5.7, 2.3],\n",
       "        [5.6, 2.8, 4.9, 2. ],\n",
       "        [7.7, 2.8, 6.7, 2. ],\n",
       "        [6.3, 2.7, 4.9, 1.8],\n",
       "        [6.7, 3.3, 5.7, 2.1],\n",
       "        [7.2, 3.2, 6. , 1.8],\n",
       "        [6.2, 2.8, 4.8, 1.8],\n",
       "        [6.1, 3. , 4.9, 1.8],\n",
       "        [6.4, 2.8, 5.6, 2.1],\n",
       "        [7.2, 3. , 5.8, 1.6],\n",
       "        [7.4, 2.8, 6.1, 1.9],\n",
       "        [7.9, 3.8, 6.4, 2. ],\n",
       "        [6.4, 2.8, 5.6, 2.2],\n",
       "        [6.3, 2.8, 5.1, 1.5],\n",
       "        [6.1, 2.6, 5.6, 1.4],\n",
       "        [7.7, 3. , 6.1, 2.3],\n",
       "        [6.3, 3.4, 5.6, 2.4],\n",
       "        [6.4, 3.1, 5.5, 1.8],\n",
       "        [6. , 3. , 4.8, 1.8],\n",
       "        [6.9, 3.1, 5.4, 2.1],\n",
       "        [6.7, 3.1, 5.6, 2.4],\n",
       "        [6.9, 3.1, 5.1, 2.3],\n",
       "        [5.8, 2.7, 5.1, 1.9],\n",
       "        [6.8, 3.2, 5.9, 2.3],\n",
       "        [6.7, 3.3, 5.7, 2.5],\n",
       "        [6.7, 3. , 5.2, 2.3],\n",
       "        [6.3, 2.5, 5. , 1.9],\n",
       "        [6.5, 3. , 5.2, 2. ],\n",
       "        [6.2, 3.4, 5.4, 2.3],\n",
       "        [5.9, 3. , 5.1, 1.8]]),\n",
       " 'target': array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n",
       "        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n",
       "        0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,\n",
       "        1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,\n",
       "        1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,\n",
       "        2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,\n",
       "        2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]),\n",
       " 'frame': None,\n",
       " 'target_names': array(['setosa', 'versicolor', 'virginica'], dtype='<U10'),\n",
       " 'DESCR': '.. _iris_dataset:\\n\\nIris plants dataset\\n--------------------\\n\\n**Data Set Characteristics:**\\n\\n    :Number of Instances: 150 (50 in each of three classes)\\n    :Number of Attributes: 4 numeric, predictive attributes and the class\\n    :Attribute Information:\\n        - sepal length in cm\\n        - sepal width in cm\\n        - petal length in cm\\n        - petal width in cm\\n        - class:\\n                - Iris-Setosa\\n                - Iris-Versicolour\\n                - Iris-Virginica\\n                \\n    :Summary Statistics:\\n\\n    ============== ==== ==== ======= ===== ====================\\n                    Min  Max   Mean    SD   Class Correlation\\n    ============== ==== ==== ======= ===== ====================\\n    sepal length:   4.3  7.9   5.84   0.83    0.7826\\n    sepal width:    2.0  4.4   3.05   0.43   -0.4194\\n    petal length:   1.0  6.9   3.76   1.76    0.9490  (high!)\\n    petal width:    0.1  2.5   1.20   0.76    0.9565  (high!)\\n    ============== ==== ==== ======= ===== ====================\\n\\n    :Missing Attribute Values: None\\n    :Class Distribution: 33.3% for each of 3 classes.\\n    :Creator: R.A. Fisher\\n    :Donor: Michael Marshall (MARSHALL%PLU@io.arc.nasa.gov)\\n    :Date: July, 1988\\n\\nThe famous Iris database, first used by Sir R.A. Fisher. The dataset is taken\\nfrom Fisher\\'s paper. Note that it\\'s the same as in R, but not as in the UCI\\nMachine Learning Repository, which has two wrong data points.\\n\\nThis is perhaps the best known database to be found in the\\npattern recognition literature.  Fisher\\'s paper is a classic in the field and\\nis referenced frequently to this day.  (See Duda & Hart, for example.)  The\\ndata set contains 3 classes of 50 instances each, where each class refers to a\\ntype of iris plant.  One class is linearly separable from the other 2; the\\nlatter are NOT linearly separable from each other.\\n\\n.. topic:: References\\n\\n   - Fisher, R.A. \"The use of multiple measurements in taxonomic problems\"\\n     Annual Eugenics, 7, Part II, 179-188 (1936); also in \"Contributions to\\n     Mathematical Statistics\" (John Wiley, NY, 1950).\\n   - Duda, R.O., & Hart, P.E. (1973) Pattern Classification and Scene Analysis.\\n     (Q327.D83) John Wiley & Sons.  ISBN 0-471-22361-1.  See page 218.\\n   - Dasarathy, B.V. (1980) \"Nosing Around the Neighborhood: A New System\\n     Structure and Classification Rule for Recognition in Partially Exposed\\n     Environments\".  IEEE Transactions on Pattern Analysis and Machine\\n     Intelligence, Vol. PAMI-2, No. 1, 67-71.\\n   - Gates, G.W. (1972) \"The Reduced Nearest Neighbor Rule\".  IEEE Transactions\\n     on Information Theory, May 1972, 431-433.\\n   - See also: 1988 MLC Proceedings, 54-64.  Cheeseman et al\"s AUTOCLASS II\\n     conceptual clustering system finds 3 classes in the data.\\n   - Many, many more ...',\n",
       " 'feature_names': ['sepal length (cm)',\n",
       "  'sepal width (cm)',\n",
       "  'petal length (cm)',\n",
       "  'petal width (cm)'],\n",
       " 'filename': 'iris.csv',\n",
       " 'data_module': 'sklearn.datasets.data'}"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "iris"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "0c32accf",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2022-06-27T13:36:38.664203Z",
     "start_time": "2022-06-27T13:36:38.424437Z"
    }
   },
   "outputs": [
    {
     "data": {
      "image/svg+xml": [
       "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n",
       "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n",
       " \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n",
       "<!-- Generated by graphviz version 2.48.0 (20210717.1556)\n",
       " -->\n",
       "<!-- Title: Tree Pages: 1 -->\n",
       "<svg width=\"847pt\" height=\"552pt\"\n",
       " viewBox=\"0.00 0.00 847.00 552.00\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n",
       "<g id=\"graph0\" class=\"graph\" transform=\"scale(1 1) rotate(0) translate(4 548)\">\n",
       "<title>Tree</title>\n",
       "<polygon fill=\"white\" stroke=\"transparent\" points=\"-4,4 -4,-548 843,-548 843,4 -4,4\"/>\n",
       "<!-- 0 -->\n",
       "<g id=\"node1\" class=\"node\">\n",
       "<title>0</title>\n",
       "<path fill=\"#ffffff\" stroke=\"black\" d=\"M505.5,-544C505.5,-544 355.5,-544 355.5,-544 349.5,-544 343.5,-538 343.5,-532 343.5,-532 343.5,-473 343.5,-473 343.5,-467 349.5,-461 355.5,-461 355.5,-461 505.5,-461 505.5,-461 511.5,-461 517.5,-467 517.5,-473 517.5,-473 517.5,-532 517.5,-532 517.5,-538 511.5,-544 505.5,-544\"/>\n",
       "<text text-anchor=\"middle\" x=\"430.5\" y=\"-528.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">petal length (cm) &lt;= 2.45</text>\n",
       "<text text-anchor=\"middle\" x=\"430.5\" y=\"-513.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 1.584</text>\n",
       "<text text-anchor=\"middle\" x=\"430.5\" y=\"-498.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 112</text>\n",
       "<text text-anchor=\"middle\" x=\"430.5\" y=\"-483.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [36, 38, 38]</text>\n",
       "<text text-anchor=\"middle\" x=\"430.5\" y=\"-468.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = versicolor</text>\n",
       "</g>\n",
       "<!-- 1 -->\n",
       "<g id=\"node2\" class=\"node\">\n",
       "<title>1</title>\n",
       "<path fill=\"#e58139\" stroke=\"black\" d=\"M398,-417.5C398,-417.5 301,-417.5 301,-417.5 295,-417.5 289,-411.5 289,-405.5 289,-405.5 289,-361.5 289,-361.5 289,-355.5 295,-349.5 301,-349.5 301,-349.5 398,-349.5 398,-349.5 404,-349.5 410,-355.5 410,-361.5 410,-361.5 410,-405.5 410,-405.5 410,-411.5 404,-417.5 398,-417.5\"/>\n",
       "<text text-anchor=\"middle\" x=\"349.5\" y=\"-402.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 0.0</text>\n",
       "<text text-anchor=\"middle\" x=\"349.5\" y=\"-387.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 36</text>\n",
       "<text text-anchor=\"middle\" x=\"349.5\" y=\"-372.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [36, 0, 0]</text>\n",
       "<text text-anchor=\"middle\" x=\"349.5\" y=\"-357.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = setosa</text>\n",
       "</g>\n",
       "<!-- 0&#45;&gt;1 -->\n",
       "<g id=\"edge1\" class=\"edge\">\n",
       "<title>0&#45;&gt;1</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M402.4,-460.91C394.61,-449.65 386.14,-437.42 378.3,-426.11\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"381.03,-423.9 372.46,-417.67 375.28,-427.88 381.03,-423.9\"/>\n",
       "<text text-anchor=\"middle\" x=\"367.99\" y=\"-438.56\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">True</text>\n",
       "</g>\n",
       "<!-- 2 -->\n",
       "<g id=\"node3\" class=\"node\">\n",
       "<title>2</title>\n",
       "<path fill=\"#ffffff\" stroke=\"black\" d=\"M584.5,-425C584.5,-425 440.5,-425 440.5,-425 434.5,-425 428.5,-419 428.5,-413 428.5,-413 428.5,-354 428.5,-354 428.5,-348 434.5,-342 440.5,-342 440.5,-342 584.5,-342 584.5,-342 590.5,-342 596.5,-348 596.5,-354 596.5,-354 596.5,-413 596.5,-413 596.5,-419 590.5,-425 584.5,-425\"/>\n",
       "<text text-anchor=\"middle\" x=\"512.5\" y=\"-409.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">petal width (cm) &lt;= 1.75</text>\n",
       "<text text-anchor=\"middle\" x=\"512.5\" y=\"-394.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 1.0</text>\n",
       "<text text-anchor=\"middle\" x=\"512.5\" y=\"-379.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 76</text>\n",
       "<text text-anchor=\"middle\" x=\"512.5\" y=\"-364.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [0, 38, 38]</text>\n",
       "<text text-anchor=\"middle\" x=\"512.5\" y=\"-349.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = versicolor</text>\n",
       "</g>\n",
       "<!-- 0&#45;&gt;2 -->\n",
       "<g id=\"edge2\" class=\"edge\">\n",
       "<title>0&#45;&gt;2</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M458.95,-460.91C465.18,-452.01 471.84,-442.51 478.28,-433.33\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"481.23,-435.22 484.1,-425.02 475.5,-431.2 481.23,-435.22\"/>\n",
       "<text text-anchor=\"middle\" x=\"488.43\" y=\"-445.94\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">False</text>\n",
       "</g>\n",
       "<!-- 3 -->\n",
       "<g id=\"node4\" class=\"node\">\n",
       "<title>3</title>\n",
       "<path fill=\"#4ee88f\" stroke=\"black\" d=\"M482.5,-306C482.5,-306 332.5,-306 332.5,-306 326.5,-306 320.5,-300 320.5,-294 320.5,-294 320.5,-235 320.5,-235 320.5,-229 326.5,-223 332.5,-223 332.5,-223 482.5,-223 482.5,-223 488.5,-223 494.5,-229 494.5,-235 494.5,-235 494.5,-294 494.5,-294 494.5,-300 488.5,-306 482.5,-306\"/>\n",
       "<text text-anchor=\"middle\" x=\"407.5\" y=\"-290.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">petal length (cm) &lt;= 4.95</text>\n",
       "<text text-anchor=\"middle\" x=\"407.5\" y=\"-275.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 0.461</text>\n",
       "<text text-anchor=\"middle\" x=\"407.5\" y=\"-260.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 41</text>\n",
       "<text text-anchor=\"middle\" x=\"407.5\" y=\"-245.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [0, 37, 4]</text>\n",
       "<text text-anchor=\"middle\" x=\"407.5\" y=\"-230.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = versicolor</text>\n",
       "</g>\n",
       "<!-- 2&#45;&gt;3 -->\n",
       "<g id=\"edge3\" class=\"edge\">\n",
       "<title>2&#45;&gt;3</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M476.07,-341.91C467.85,-332.74 459.04,-322.93 450.57,-313.49\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"453.15,-311.13 443.86,-306.02 447.94,-315.8 453.15,-311.13\"/>\n",
       "</g>\n",
       "<!-- 10 -->\n",
       "<g id=\"node11\" class=\"node\">\n",
       "<title>10</title>\n",
       "<path fill=\"#853fe6\" stroke=\"black\" d=\"M692.5,-306C692.5,-306 542.5,-306 542.5,-306 536.5,-306 530.5,-300 530.5,-294 530.5,-294 530.5,-235 530.5,-235 530.5,-229 536.5,-223 542.5,-223 542.5,-223 692.5,-223 692.5,-223 698.5,-223 704.5,-229 704.5,-235 704.5,-235 704.5,-294 704.5,-294 704.5,-300 698.5,-306 692.5,-306\"/>\n",
       "<text text-anchor=\"middle\" x=\"617.5\" y=\"-290.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">petal length (cm) &lt;= 4.85</text>\n",
       "<text text-anchor=\"middle\" x=\"617.5\" y=\"-275.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 0.187</text>\n",
       "<text text-anchor=\"middle\" x=\"617.5\" y=\"-260.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 35</text>\n",
       "<text text-anchor=\"middle\" x=\"617.5\" y=\"-245.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [0, 1, 34]</text>\n",
       "<text text-anchor=\"middle\" x=\"617.5\" y=\"-230.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = virginica</text>\n",
       "</g>\n",
       "<!-- 2&#45;&gt;10 -->\n",
       "<g id=\"edge10\" class=\"edge\">\n",
       "<title>2&#45;&gt;10</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M548.93,-341.91C557.15,-332.74 565.96,-322.93 574.43,-313.49\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"577.06,-315.8 581.14,-306.02 571.85,-311.13 577.06,-315.8\"/>\n",
       "</g>\n",
       "<!-- 4 -->\n",
       "<g id=\"node5\" class=\"node\">\n",
       "<title>4</title>\n",
       "<path fill=\"#3fe685\" stroke=\"black\" d=\"M275.5,-187C275.5,-187 131.5,-187 131.5,-187 125.5,-187 119.5,-181 119.5,-175 119.5,-175 119.5,-116 119.5,-116 119.5,-110 125.5,-104 131.5,-104 131.5,-104 275.5,-104 275.5,-104 281.5,-104 287.5,-110 287.5,-116 287.5,-116 287.5,-175 287.5,-175 287.5,-181 281.5,-187 275.5,-187\"/>\n",
       "<text text-anchor=\"middle\" x=\"203.5\" y=\"-171.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">petal width (cm) &lt;= 1.65</text>\n",
       "<text text-anchor=\"middle\" x=\"203.5\" y=\"-156.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 0.183</text>\n",
       "<text text-anchor=\"middle\" x=\"203.5\" y=\"-141.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 36</text>\n",
       "<text text-anchor=\"middle\" x=\"203.5\" y=\"-126.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [0, 35, 1]</text>\n",
       "<text text-anchor=\"middle\" x=\"203.5\" y=\"-111.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = versicolor</text>\n",
       "</g>\n",
       "<!-- 3&#45;&gt;4 -->\n",
       "<g id=\"edge4\" class=\"edge\">\n",
       "<title>3&#45;&gt;4</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M336.72,-222.91C319.48,-213.02 300.91,-202.37 283.28,-192.25\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"284.57,-188.96 274.15,-187.02 281.08,-195.03 284.57,-188.96\"/>\n",
       "</g>\n",
       "<!-- 7 -->\n",
       "<g id=\"node8\" class=\"node\">\n",
       "<title>7</title>\n",
       "<path fill=\"#d5bdf6\" stroke=\"black\" d=\"M479.5,-187C479.5,-187 335.5,-187 335.5,-187 329.5,-187 323.5,-181 323.5,-175 323.5,-175 323.5,-116 323.5,-116 323.5,-110 329.5,-104 335.5,-104 335.5,-104 479.5,-104 479.5,-104 485.5,-104 491.5,-110 491.5,-116 491.5,-116 491.5,-175 491.5,-175 491.5,-181 485.5,-187 479.5,-187\"/>\n",
       "<text text-anchor=\"middle\" x=\"407.5\" y=\"-171.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">petal width (cm) &lt;= 1.55</text>\n",
       "<text text-anchor=\"middle\" x=\"407.5\" y=\"-156.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 0.971</text>\n",
       "<text text-anchor=\"middle\" x=\"407.5\" y=\"-141.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 5</text>\n",
       "<text text-anchor=\"middle\" x=\"407.5\" y=\"-126.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [0, 2, 3]</text>\n",
       "<text text-anchor=\"middle\" x=\"407.5\" y=\"-111.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = virginica</text>\n",
       "</g>\n",
       "<!-- 3&#45;&gt;7 -->\n",
       "<g id=\"edge7\" class=\"edge\">\n",
       "<title>3&#45;&gt;7</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M407.5,-222.91C407.5,-214.65 407.5,-205.86 407.5,-197.3\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"411,-197.02 407.5,-187.02 404,-197.02 411,-197.02\"/>\n",
       "</g>\n",
       "<!-- 5 -->\n",
       "<g id=\"node6\" class=\"node\">\n",
       "<title>5</title>\n",
       "<path fill=\"#39e581\" stroke=\"black\" d=\"M115,-68C115,-68 12,-68 12,-68 6,-68 0,-62 0,-56 0,-56 0,-12 0,-12 0,-6 6,0 12,0 12,0 115,0 115,0 121,0 127,-6 127,-12 127,-12 127,-56 127,-56 127,-62 121,-68 115,-68\"/>\n",
       "<text text-anchor=\"middle\" x=\"63.5\" y=\"-52.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 0.0</text>\n",
       "<text text-anchor=\"middle\" x=\"63.5\" y=\"-37.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 35</text>\n",
       "<text text-anchor=\"middle\" x=\"63.5\" y=\"-22.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [0, 35, 0]</text>\n",
       "<text text-anchor=\"middle\" x=\"63.5\" y=\"-7.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = versicolor</text>\n",
       "</g>\n",
       "<!-- 4&#45;&gt;5 -->\n",
       "<g id=\"edge5\" class=\"edge\">\n",
       "<title>4&#45;&gt;5</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M151.37,-103.73C139.24,-94.24 126.35,-84.16 114.28,-74.72\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"116.11,-71.7 106.07,-68.3 111.8,-77.22 116.11,-71.7\"/>\n",
       "</g>\n",
       "<!-- 6 -->\n",
       "<g id=\"node7\" class=\"node\">\n",
       "<title>6</title>\n",
       "<path fill=\"#8139e5\" stroke=\"black\" d=\"M249.5,-68C249.5,-68 157.5,-68 157.5,-68 151.5,-68 145.5,-62 145.5,-56 145.5,-56 145.5,-12 145.5,-12 145.5,-6 151.5,0 157.5,0 157.5,0 249.5,0 249.5,0 255.5,0 261.5,-6 261.5,-12 261.5,-12 261.5,-56 261.5,-56 261.5,-62 255.5,-68 249.5,-68\"/>\n",
       "<text text-anchor=\"middle\" x=\"203.5\" y=\"-52.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 0.0</text>\n",
       "<text text-anchor=\"middle\" x=\"203.5\" y=\"-37.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 1</text>\n",
       "<text text-anchor=\"middle\" x=\"203.5\" y=\"-22.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [0, 0, 1]</text>\n",
       "<text text-anchor=\"middle\" x=\"203.5\" y=\"-7.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = virginica</text>\n",
       "</g>\n",
       "<!-- 4&#45;&gt;6 -->\n",
       "<g id=\"edge6\" class=\"edge\">\n",
       "<title>4&#45;&gt;6</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M203.5,-103.73C203.5,-95.52 203.5,-86.86 203.5,-78.56\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"207,-78.3 203.5,-68.3 200,-78.3 207,-78.3\"/>\n",
       "</g>\n",
       "<!-- 8 -->\n",
       "<g id=\"node9\" class=\"node\">\n",
       "<title>8</title>\n",
       "<path fill=\"#8139e5\" stroke=\"black\" d=\"M383.5,-68C383.5,-68 291.5,-68 291.5,-68 285.5,-68 279.5,-62 279.5,-56 279.5,-56 279.5,-12 279.5,-12 279.5,-6 285.5,0 291.5,0 291.5,0 383.5,0 383.5,0 389.5,0 395.5,-6 395.5,-12 395.5,-12 395.5,-56 395.5,-56 395.5,-62 389.5,-68 383.5,-68\"/>\n",
       "<text text-anchor=\"middle\" x=\"337.5\" y=\"-52.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 0.0</text>\n",
       "<text text-anchor=\"middle\" x=\"337.5\" y=\"-37.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 3</text>\n",
       "<text text-anchor=\"middle\" x=\"337.5\" y=\"-22.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [0, 0, 3]</text>\n",
       "<text text-anchor=\"middle\" x=\"337.5\" y=\"-7.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = virginica</text>\n",
       "</g>\n",
       "<!-- 7&#45;&gt;8 -->\n",
       "<g id=\"edge8\" class=\"edge\">\n",
       "<title>7&#45;&gt;8</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M381.43,-103.73C375.84,-94.97 369.91,-85.7 364.29,-76.91\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"367.12,-74.84 358.79,-68.3 361.22,-78.61 367.12,-74.84\"/>\n",
       "</g>\n",
       "<!-- 9 -->\n",
       "<g id=\"node10\" class=\"node\">\n",
       "<title>9</title>\n",
       "<path fill=\"#39e581\" stroke=\"black\" d=\"M529,-68C529,-68 426,-68 426,-68 420,-68 414,-62 414,-56 414,-56 414,-12 414,-12 414,-6 420,0 426,0 426,0 529,0 529,0 535,0 541,-6 541,-12 541,-12 541,-56 541,-56 541,-62 535,-68 529,-68\"/>\n",
       "<text text-anchor=\"middle\" x=\"477.5\" y=\"-52.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 0.0</text>\n",
       "<text text-anchor=\"middle\" x=\"477.5\" y=\"-37.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 2</text>\n",
       "<text text-anchor=\"middle\" x=\"477.5\" y=\"-22.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [0, 2, 0]</text>\n",
       "<text text-anchor=\"middle\" x=\"477.5\" y=\"-7.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = versicolor</text>\n",
       "</g>\n",
       "<!-- 7&#45;&gt;9 -->\n",
       "<g id=\"edge9\" class=\"edge\">\n",
       "<title>7&#45;&gt;9</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M433.57,-103.73C439.16,-94.97 445.09,-85.7 450.71,-76.91\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"453.78,-78.61 456.21,-68.3 447.88,-74.84 453.78,-78.61\"/>\n",
       "</g>\n",
       "<!-- 11 -->\n",
       "<g id=\"node12\" class=\"node\">\n",
       "<title>11</title>\n",
       "<path fill=\"#ffffff\" stroke=\"black\" d=\"M687.5,-187C687.5,-187 547.5,-187 547.5,-187 541.5,-187 535.5,-181 535.5,-175 535.5,-175 535.5,-116 535.5,-116 535.5,-110 541.5,-104 547.5,-104 547.5,-104 687.5,-104 687.5,-104 693.5,-104 699.5,-110 699.5,-116 699.5,-116 699.5,-175 699.5,-175 699.5,-181 693.5,-187 687.5,-187\"/>\n",
       "<text text-anchor=\"middle\" x=\"617.5\" y=\"-171.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">sepal width (cm) &lt;= 3.1</text>\n",
       "<text text-anchor=\"middle\" x=\"617.5\" y=\"-156.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 1.0</text>\n",
       "<text text-anchor=\"middle\" x=\"617.5\" y=\"-141.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 2</text>\n",
       "<text text-anchor=\"middle\" x=\"617.5\" y=\"-126.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [0, 1, 1]</text>\n",
       "<text text-anchor=\"middle\" x=\"617.5\" y=\"-111.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = versicolor</text>\n",
       "</g>\n",
       "<!-- 10&#45;&gt;11 -->\n",
       "<g id=\"edge11\" class=\"edge\">\n",
       "<title>10&#45;&gt;11</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M617.5,-222.91C617.5,-214.65 617.5,-205.86 617.5,-197.3\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"621,-197.02 617.5,-187.02 614,-197.02 621,-197.02\"/>\n",
       "</g>\n",
       "<!-- 14 -->\n",
       "<g id=\"node15\" class=\"node\">\n",
       "<title>14</title>\n",
       "<path fill=\"#8139e5\" stroke=\"black\" d=\"M827,-179.5C827,-179.5 730,-179.5 730,-179.5 724,-179.5 718,-173.5 718,-167.5 718,-167.5 718,-123.5 718,-123.5 718,-117.5 724,-111.5 730,-111.5 730,-111.5 827,-111.5 827,-111.5 833,-111.5 839,-117.5 839,-123.5 839,-123.5 839,-167.5 839,-167.5 839,-173.5 833,-179.5 827,-179.5\"/>\n",
       "<text text-anchor=\"middle\" x=\"778.5\" y=\"-164.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 0.0</text>\n",
       "<text text-anchor=\"middle\" x=\"778.5\" y=\"-149.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 33</text>\n",
       "<text text-anchor=\"middle\" x=\"778.5\" y=\"-134.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [0, 0, 33]</text>\n",
       "<text text-anchor=\"middle\" x=\"778.5\" y=\"-119.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = virginica</text>\n",
       "</g>\n",
       "<!-- 10&#45;&gt;14 -->\n",
       "<g id=\"edge14\" class=\"edge\">\n",
       "<title>10&#45;&gt;14</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M673.36,-222.91C689.91,-210.88 708,-197.73 724.43,-185.79\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"726.83,-188.38 732.86,-179.67 722.71,-182.71 726.83,-188.38\"/>\n",
       "</g>\n",
       "<!-- 12 -->\n",
       "<g id=\"node13\" class=\"node\">\n",
       "<title>12</title>\n",
       "<path fill=\"#8139e5\" stroke=\"black\" d=\"M663.5,-68C663.5,-68 571.5,-68 571.5,-68 565.5,-68 559.5,-62 559.5,-56 559.5,-56 559.5,-12 559.5,-12 559.5,-6 565.5,0 571.5,0 571.5,0 663.5,0 663.5,0 669.5,0 675.5,-6 675.5,-12 675.5,-12 675.5,-56 675.5,-56 675.5,-62 669.5,-68 663.5,-68\"/>\n",
       "<text text-anchor=\"middle\" x=\"617.5\" y=\"-52.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 0.0</text>\n",
       "<text text-anchor=\"middle\" x=\"617.5\" y=\"-37.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 1</text>\n",
       "<text text-anchor=\"middle\" x=\"617.5\" y=\"-22.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [0, 0, 1]</text>\n",
       "<text text-anchor=\"middle\" x=\"617.5\" y=\"-7.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = virginica</text>\n",
       "</g>\n",
       "<!-- 11&#45;&gt;12 -->\n",
       "<g id=\"edge12\" class=\"edge\">\n",
       "<title>11&#45;&gt;12</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M617.5,-103.73C617.5,-95.52 617.5,-86.86 617.5,-78.56\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"621,-78.3 617.5,-68.3 614,-78.3 621,-78.3\"/>\n",
       "</g>\n",
       "<!-- 13 -->\n",
       "<g id=\"node14\" class=\"node\">\n",
       "<title>13</title>\n",
       "<path fill=\"#39e581\" stroke=\"black\" d=\"M809,-68C809,-68 706,-68 706,-68 700,-68 694,-62 694,-56 694,-56 694,-12 694,-12 694,-6 700,0 706,0 706,0 809,0 809,0 815,0 821,-6 821,-12 821,-12 821,-56 821,-56 821,-62 815,-68 809,-68\"/>\n",
       "<text text-anchor=\"middle\" x=\"757.5\" y=\"-52.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 0.0</text>\n",
       "<text text-anchor=\"middle\" x=\"757.5\" y=\"-37.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 1</text>\n",
       "<text text-anchor=\"middle\" x=\"757.5\" y=\"-22.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [0, 1, 0]</text>\n",
       "<text text-anchor=\"middle\" x=\"757.5\" y=\"-7.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = versicolor</text>\n",
       "</g>\n",
       "<!-- 11&#45;&gt;13 -->\n",
       "<g id=\"edge13\" class=\"edge\">\n",
       "<title>11&#45;&gt;13</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M669.63,-103.73C681.76,-94.24 694.65,-84.16 706.72,-74.72\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"709.2,-77.22 714.93,-68.3 704.89,-71.7 709.2,-77.22\"/>\n",
       "</g>\n",
       "</g>\n",
       "</svg>\n"
      ],
      "text/plain": [
       "<graphviz.sources.Source at 0x27afb1bed90>"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import graphviz\n",
    "from sklearn import tree\n",
    "# 导出数据\n",
    "dot_data = tree.export_graphviz(model,feature_names= iris['feature_names'],\n",
    "                     class_names= name,# 类别名\n",
    "                     filled=True, # 填充颜色\n",
    "                     rounded=True,)\n",
    "graph = graphviz.Source(dot_data)\n",
    "graph"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "da0f0d3e",
   "metadata": {},
   "source": [
    "#### 决策树的剪枝"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "0a4fd007",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2022-06-27T13:43:37.252823Z",
     "start_time": "2022-06-27T13:43:37.118729Z"
    },
    "collapsed": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "准确率是： 0.6842105263157895\n"
     ]
    },
    {
     "data": {
      "image/svg+xml": [
       "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n",
       "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n",
       " \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n",
       "<!-- Generated by graphviz version 2.48.0 (20210717.1556)\n",
       " -->\n",
       "<!-- Title: Tree Pages: 1 -->\n",
       "<svg width=\"276pt\" height=\"195pt\"\n",
       " viewBox=\"0.00 0.00 276.00 195.00\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n",
       "<g id=\"graph0\" class=\"graph\" transform=\"scale(1 1) rotate(0) translate(4 191)\">\n",
       "<title>Tree</title>\n",
       "<polygon fill=\"white\" stroke=\"transparent\" points=\"-4,4 -4,-191 272,-191 272,4 -4,4\"/>\n",
       "<!-- 0 -->\n",
       "<g id=\"node1\" class=\"node\">\n",
       "<title>0</title>\n",
       "<path fill=\"#ffffff\" stroke=\"black\" d=\"M206.5,-187C206.5,-187 56.5,-187 56.5,-187 50.5,-187 44.5,-181 44.5,-175 44.5,-175 44.5,-116 44.5,-116 44.5,-110 50.5,-104 56.5,-104 56.5,-104 206.5,-104 206.5,-104 212.5,-104 218.5,-110 218.5,-116 218.5,-116 218.5,-175 218.5,-175 218.5,-181 212.5,-187 206.5,-187\"/>\n",
       "<text text-anchor=\"middle\" x=\"131.5\" y=\"-171.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">petal length (cm) &lt;= 2.45</text>\n",
       "<text text-anchor=\"middle\" x=\"131.5\" y=\"-156.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 1.584</text>\n",
       "<text text-anchor=\"middle\" x=\"131.5\" y=\"-141.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 112</text>\n",
       "<text text-anchor=\"middle\" x=\"131.5\" y=\"-126.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [36, 38, 38]</text>\n",
       "<text text-anchor=\"middle\" x=\"131.5\" y=\"-111.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = versicolor</text>\n",
       "</g>\n",
       "<!-- 1 -->\n",
       "<g id=\"node2\" class=\"node\">\n",
       "<title>1</title>\n",
       "<path fill=\"#e58139\" stroke=\"black\" d=\"M109,-68C109,-68 12,-68 12,-68 6,-68 0,-62 0,-56 0,-56 0,-12 0,-12 0,-6 6,0 12,0 12,0 109,0 109,0 115,0 121,-6 121,-12 121,-12 121,-56 121,-56 121,-62 115,-68 109,-68\"/>\n",
       "<text text-anchor=\"middle\" x=\"60.5\" y=\"-52.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 0.0</text>\n",
       "<text text-anchor=\"middle\" x=\"60.5\" y=\"-37.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 36</text>\n",
       "<text text-anchor=\"middle\" x=\"60.5\" y=\"-22.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [36, 0, 0]</text>\n",
       "<text text-anchor=\"middle\" x=\"60.5\" y=\"-7.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = setosa</text>\n",
       "</g>\n",
       "<!-- 0&#45;&gt;1 -->\n",
       "<g id=\"edge1\" class=\"edge\">\n",
       "<title>0&#45;&gt;1</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M105.06,-103.73C99.38,-94.97 93.38,-85.7 87.67,-76.91\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"90.47,-74.79 82.09,-68.3 84.6,-78.59 90.47,-74.79\"/>\n",
       "<text text-anchor=\"middle\" x=\"76.88\" y=\"-89.05\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">True</text>\n",
       "</g>\n",
       "<!-- 2 -->\n",
       "<g id=\"node3\" class=\"node\">\n",
       "<title>2</title>\n",
       "<path fill=\"#ffffff\" stroke=\"black\" d=\"M256,-68C256,-68 151,-68 151,-68 145,-68 139,-62 139,-56 139,-56 139,-12 139,-12 139,-6 145,0 151,0 151,0 256,0 256,0 262,0 268,-6 268,-12 268,-12 268,-56 268,-56 268,-62 262,-68 256,-68\"/>\n",
       "<text text-anchor=\"middle\" x=\"203.5\" y=\"-52.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 1.0</text>\n",
       "<text text-anchor=\"middle\" x=\"203.5\" y=\"-37.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 76</text>\n",
       "<text text-anchor=\"middle\" x=\"203.5\" y=\"-22.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [0, 38, 38]</text>\n",
       "<text text-anchor=\"middle\" x=\"203.5\" y=\"-7.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = versicolor</text>\n",
       "</g>\n",
       "<!-- 0&#45;&gt;2 -->\n",
       "<g id=\"edge2\" class=\"edge\">\n",
       "<title>0&#45;&gt;2</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M158.31,-103.73C164.07,-94.97 170.16,-85.7 175.95,-76.91\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"179.03,-78.58 181.6,-68.3 173.19,-74.73 179.03,-78.58\"/>\n",
       "<text text-anchor=\"middle\" x=\"186.66\" y=\"-89.08\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">False</text>\n",
       "</g>\n",
       "</g>\n",
       "</svg>\n"
      ],
      "text/plain": [
       "<graphviz.sources.Source at 0x27afb1ba340>"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# max_depth调整树深度：剪枝操作\n",
    "model = DecisionTreeClassifier(max_depth= 1,criterion='entropy')\n",
    "model.fit(X_train,y_train)\n",
    "print('准确率是：',model.score(X_test,y_test))\n",
    "dot_data = tree.export_graphviz(model,feature_names= iris['feature_names'],\n",
    "                     class_names= name,# 类别名\n",
    "                     filled=True, # 填充颜色\n",
    "                     rounded=True,)\n",
    "graph = graphviz.Source(dot_data)\n",
    "graph"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "ec9a3988",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2022-06-27T13:52:57.505787Z",
     "start_time": "2022-06-27T13:52:57.395269Z"
    },
    "collapsed": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "准确率是： 0.9736842105263158\n"
     ]
    },
    {
     "data": {
      "image/svg+xml": [
       "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n",
       "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n",
       " \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n",
       "<!-- Generated by graphviz version 2.48.0 (20210717.1556)\n",
       " -->\n",
       "<!-- Title: Tree Pages: 1 -->\n",
       "<svg width=\"363pt\" height=\"314pt\"\n",
       " viewBox=\"0.00 0.00 363.00 314.00\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n",
       "<g id=\"graph0\" class=\"graph\" transform=\"scale(1 1) rotate(0) translate(4 310)\">\n",
       "<title>Tree</title>\n",
       "<polygon fill=\"white\" stroke=\"transparent\" points=\"-4,4 -4,-310 359,-310 359,4 -4,4\"/>\n",
       "<!-- 0 -->\n",
       "<g id=\"node1\" class=\"node\">\n",
       "<title>0</title>\n",
       "<path fill=\"#ffffff\" stroke=\"black\" d=\"M209.5,-306C209.5,-306 73.5,-306 73.5,-306 67.5,-306 61.5,-300 61.5,-294 61.5,-294 61.5,-235 61.5,-235 61.5,-229 67.5,-223 73.5,-223 73.5,-223 209.5,-223 209.5,-223 215.5,-223 221.5,-229 221.5,-235 221.5,-235 221.5,-294 221.5,-294 221.5,-300 215.5,-306 209.5,-306\"/>\n",
       "<text text-anchor=\"middle\" x=\"141.5\" y=\"-290.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">petal width (cm) &lt;= 0.8</text>\n",
       "<text text-anchor=\"middle\" x=\"141.5\" y=\"-275.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 1.584</text>\n",
       "<text text-anchor=\"middle\" x=\"141.5\" y=\"-260.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 112</text>\n",
       "<text text-anchor=\"middle\" x=\"141.5\" y=\"-245.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [36, 38, 38]</text>\n",
       "<text text-anchor=\"middle\" x=\"141.5\" y=\"-230.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = versicolor</text>\n",
       "</g>\n",
       "<!-- 1 -->\n",
       "<g id=\"node2\" class=\"node\">\n",
       "<title>1</title>\n",
       "<path fill=\"#e58139\" stroke=\"black\" d=\"M109,-179.5C109,-179.5 12,-179.5 12,-179.5 6,-179.5 0,-173.5 0,-167.5 0,-167.5 0,-123.5 0,-123.5 0,-117.5 6,-111.5 12,-111.5 12,-111.5 109,-111.5 109,-111.5 115,-111.5 121,-117.5 121,-123.5 121,-123.5 121,-167.5 121,-167.5 121,-173.5 115,-179.5 109,-179.5\"/>\n",
       "<text text-anchor=\"middle\" x=\"60.5\" y=\"-164.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 0.0</text>\n",
       "<text text-anchor=\"middle\" x=\"60.5\" y=\"-149.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 36</text>\n",
       "<text text-anchor=\"middle\" x=\"60.5\" y=\"-134.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [36, 0, 0]</text>\n",
       "<text text-anchor=\"middle\" x=\"60.5\" y=\"-119.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = setosa</text>\n",
       "</g>\n",
       "<!-- 0&#45;&gt;1 -->\n",
       "<g id=\"edge1\" class=\"edge\">\n",
       "<title>0&#45;&gt;1</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M113.4,-222.91C105.61,-211.65 97.14,-199.42 89.3,-188.11\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"92.03,-185.9 83.46,-179.67 86.28,-189.88 92.03,-185.9\"/>\n",
       "<text text-anchor=\"middle\" x=\"78.99\" y=\"-200.56\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">True</text>\n",
       "</g>\n",
       "<!-- 2 -->\n",
       "<g id=\"node3\" class=\"node\">\n",
       "<title>2</title>\n",
       "<path fill=\"#ffffff\" stroke=\"black\" d=\"M295.5,-187C295.5,-187 151.5,-187 151.5,-187 145.5,-187 139.5,-181 139.5,-175 139.5,-175 139.5,-116 139.5,-116 139.5,-110 145.5,-104 151.5,-104 151.5,-104 295.5,-104 295.5,-104 301.5,-104 307.5,-110 307.5,-116 307.5,-116 307.5,-175 307.5,-175 307.5,-181 301.5,-187 295.5,-187\"/>\n",
       "<text text-anchor=\"middle\" x=\"223.5\" y=\"-171.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">petal width (cm) &lt;= 1.75</text>\n",
       "<text text-anchor=\"middle\" x=\"223.5\" y=\"-156.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 1.0</text>\n",
       "<text text-anchor=\"middle\" x=\"223.5\" y=\"-141.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 76</text>\n",
       "<text text-anchor=\"middle\" x=\"223.5\" y=\"-126.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [0, 38, 38]</text>\n",
       "<text text-anchor=\"middle\" x=\"223.5\" y=\"-111.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = versicolor</text>\n",
       "</g>\n",
       "<!-- 0&#45;&gt;2 -->\n",
       "<g id=\"edge2\" class=\"edge\">\n",
       "<title>0&#45;&gt;2</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M169.95,-222.91C176.18,-214.01 182.84,-204.51 189.28,-195.33\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"192.23,-197.22 195.1,-187.02 186.5,-193.2 192.23,-197.22\"/>\n",
       "<text text-anchor=\"middle\" x=\"199.43\" y=\"-207.94\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">False</text>\n",
       "</g>\n",
       "<!-- 3 -->\n",
       "<g id=\"node4\" class=\"node\">\n",
       "<title>3</title>\n",
       "<path fill=\"#4ee88f\" stroke=\"black\" d=\"M204,-68C204,-68 101,-68 101,-68 95,-68 89,-62 89,-56 89,-56 89,-12 89,-12 89,-6 95,0 101,0 101,0 204,0 204,0 210,0 216,-6 216,-12 216,-12 216,-56 216,-56 216,-62 210,-68 204,-68\"/>\n",
       "<text text-anchor=\"middle\" x=\"152.5\" y=\"-52.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 0.461</text>\n",
       "<text text-anchor=\"middle\" x=\"152.5\" y=\"-37.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 41</text>\n",
       "<text text-anchor=\"middle\" x=\"152.5\" y=\"-22.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [0, 37, 4]</text>\n",
       "<text text-anchor=\"middle\" x=\"152.5\" y=\"-7.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = versicolor</text>\n",
       "</g>\n",
       "<!-- 2&#45;&gt;3 -->\n",
       "<g id=\"edge3\" class=\"edge\">\n",
       "<title>2&#45;&gt;3</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M197.06,-103.73C191.38,-94.97 185.38,-85.7 179.67,-76.91\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"182.47,-74.79 174.09,-68.3 176.6,-78.59 182.47,-74.79\"/>\n",
       "</g>\n",
       "<!-- 4 -->\n",
       "<g id=\"node5\" class=\"node\">\n",
       "<title>4</title>\n",
       "<path fill=\"#853fe6\" stroke=\"black\" d=\"M343,-68C343,-68 246,-68 246,-68 240,-68 234,-62 234,-56 234,-56 234,-12 234,-12 234,-6 240,0 246,0 246,0 343,0 343,0 349,0 355,-6 355,-12 355,-12 355,-56 355,-56 355,-62 349,-68 343,-68\"/>\n",
       "<text text-anchor=\"middle\" x=\"294.5\" y=\"-52.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 0.187</text>\n",
       "<text text-anchor=\"middle\" x=\"294.5\" y=\"-37.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 35</text>\n",
       "<text text-anchor=\"middle\" x=\"294.5\" y=\"-22.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [0, 1, 34]</text>\n",
       "<text text-anchor=\"middle\" x=\"294.5\" y=\"-7.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = virginica</text>\n",
       "</g>\n",
       "<!-- 2&#45;&gt;4 -->\n",
       "<g id=\"edge4\" class=\"edge\">\n",
       "<title>2&#45;&gt;4</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M249.94,-103.73C255.62,-94.97 261.62,-85.7 267.33,-76.91\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"270.4,-78.59 272.91,-68.3 264.53,-74.79 270.4,-78.59\"/>\n",
       "</g>\n",
       "</g>\n",
       "</svg>\n"
      ],
      "text/plain": [
       "<graphviz.sources.Source at 0x27afbaf50a0>"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# min_impurity_decrease（节点划分最小不纯度）：剪枝操作\n",
    "# 如果节点的不纯度（gini系数、信息熵）小于这个阈值，不分裂\n",
    "# 鸡肋，一点点肉，不值当，gini变化，放弃\n",
    "model = DecisionTreeClassifier(min_impurity_decrease = 0.2,criterion='entropy')\n",
    "model.fit(X_train,y_train)\n",
    "print('准确率是：',model.score(X_test,y_test))\n",
    "dot_data = tree.export_graphviz(model,feature_names= iris['feature_names'],\n",
    "                     class_names= name,# 类别名\n",
    "                     filled=True, # 填充颜色\n",
    "                     rounded=True,)\n",
    "graph = graphviz.Source(dot_data)\n",
    "graph"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "id": "31de387b",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2022-06-27T13:50:34.544856Z",
     "start_time": "2022-06-27T13:50:34.427613Z"
    },
    "collapsed": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "准确率是： 0.6842105263157895\n"
     ]
    },
    {
     "data": {
      "image/svg+xml": [
       "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n",
       "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n",
       " \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n",
       "<!-- Generated by graphviz version 2.48.0 (20210717.1556)\n",
       " -->\n",
       "<!-- Title: Tree Pages: 1 -->\n",
       "<svg width=\"276pt\" height=\"195pt\"\n",
       " viewBox=\"0.00 0.00 276.00 195.00\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n",
       "<g id=\"graph0\" class=\"graph\" transform=\"scale(1 1) rotate(0) translate(4 191)\">\n",
       "<title>Tree</title>\n",
       "<polygon fill=\"white\" stroke=\"transparent\" points=\"-4,4 -4,-191 272,-191 272,4 -4,4\"/>\n",
       "<!-- 0 -->\n",
       "<g id=\"node1\" class=\"node\">\n",
       "<title>0</title>\n",
       "<path fill=\"#ffffff\" stroke=\"black\" d=\"M206.5,-187C206.5,-187 56.5,-187 56.5,-187 50.5,-187 44.5,-181 44.5,-175 44.5,-175 44.5,-116 44.5,-116 44.5,-110 50.5,-104 56.5,-104 56.5,-104 206.5,-104 206.5,-104 212.5,-104 218.5,-110 218.5,-116 218.5,-116 218.5,-175 218.5,-175 218.5,-181 212.5,-187 206.5,-187\"/>\n",
       "<text text-anchor=\"middle\" x=\"131.5\" y=\"-171.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">petal length (cm) &lt;= 3.55</text>\n",
       "<text text-anchor=\"middle\" x=\"131.5\" y=\"-156.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 1.584</text>\n",
       "<text text-anchor=\"middle\" x=\"131.5\" y=\"-141.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 112</text>\n",
       "<text text-anchor=\"middle\" x=\"131.5\" y=\"-126.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [36, 38, 38]</text>\n",
       "<text text-anchor=\"middle\" x=\"131.5\" y=\"-111.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = versicolor</text>\n",
       "</g>\n",
       "<!-- 1 -->\n",
       "<g id=\"node2\" class=\"node\">\n",
       "<title>1</title>\n",
       "<path fill=\"#e99254\" stroke=\"black\" d=\"M109,-68C109,-68 12,-68 12,-68 6,-68 0,-62 0,-56 0,-56 0,-12 0,-12 0,-6 6,0 12,0 12,0 109,0 109,0 115,0 121,-6 121,-12 121,-12 121,-56 121,-56 121,-62 115,-68 109,-68\"/>\n",
       "<text text-anchor=\"middle\" x=\"60.5\" y=\"-52.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 0.535</text>\n",
       "<text text-anchor=\"middle\" x=\"60.5\" y=\"-37.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 41</text>\n",
       "<text text-anchor=\"middle\" x=\"60.5\" y=\"-22.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [36, 5, 0]</text>\n",
       "<text text-anchor=\"middle\" x=\"60.5\" y=\"-7.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = setosa</text>\n",
       "</g>\n",
       "<!-- 0&#45;&gt;1 -->\n",
       "<g id=\"edge1\" class=\"edge\">\n",
       "<title>0&#45;&gt;1</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M105.06,-103.73C99.38,-94.97 93.38,-85.7 87.67,-76.91\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"90.47,-74.79 82.09,-68.3 84.6,-78.59 90.47,-74.79\"/>\n",
       "<text text-anchor=\"middle\" x=\"76.88\" y=\"-89.05\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">True</text>\n",
       "</g>\n",
       "<!-- 2 -->\n",
       "<g id=\"node3\" class=\"node\">\n",
       "<title>2</title>\n",
       "<path fill=\"#eee5fc\" stroke=\"black\" d=\"M256,-68C256,-68 151,-68 151,-68 145,-68 139,-62 139,-56 139,-56 139,-12 139,-12 139,-6 145,0 151,0 151,0 256,0 256,0 262,0 268,-6 268,-12 268,-12 268,-56 268,-56 268,-62 262,-68 256,-68\"/>\n",
       "<text text-anchor=\"middle\" x=\"203.5\" y=\"-52.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 0.996</text>\n",
       "<text text-anchor=\"middle\" x=\"203.5\" y=\"-37.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 71</text>\n",
       "<text text-anchor=\"middle\" x=\"203.5\" y=\"-22.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [0, 33, 38]</text>\n",
       "<text text-anchor=\"middle\" x=\"203.5\" y=\"-7.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = virginica</text>\n",
       "</g>\n",
       "<!-- 0&#45;&gt;2 -->\n",
       "<g id=\"edge2\" class=\"edge\">\n",
       "<title>0&#45;&gt;2</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M158.31,-103.73C164.07,-94.97 170.16,-85.7 175.95,-76.91\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"179.03,-78.58 181.6,-68.3 173.19,-74.73 179.03,-78.58\"/>\n",
       "<text text-anchor=\"middle\" x=\"186.66\" y=\"-89.08\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">False</text>\n",
       "</g>\n",
       "</g>\n",
       "</svg>\n"
      ],
      "text/plain": [
       "<graphviz.sources.Source at 0x27afbaf4430>"
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# min_samples_leaf 叶子节点最少样本树\n",
    "model = DecisionTreeClassifier(min_samples_leaf=40,criterion='entropy')\n",
    "model.fit(X_train,y_train)\n",
    "print('准确率是：',model.score(X_test,y_test))\n",
    "dot_data = tree.export_graphviz(model,feature_names= iris['feature_names'],\n",
    "                     class_names= name,# 类别名\n",
    "                     filled=True, # 填充颜色\n",
    "                     rounded=True,)\n",
    "graph = graphviz.Source(dot_data)\n",
    "graph"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "bebd8abe",
   "metadata": {},
   "source": [
    "#### 选择合适超参数【max_depth】"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "a9d50b7f",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2022-06-27T13:58:53.256219Z",
     "start_time": "2022-06-27T13:58:53.107709Z"
    }
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAjIAAAGHCAYAAACqI7gCAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/YYfK9AAAACXBIWXMAAAsTAAALEwEAmpwYAAAuwklEQVR4nO3deZhcZZn///edjdAsYQkJIVUkLA6CC4tRUBgIuCvKODMOKiqOo3Hc/bmijvp1wXVcR5wh7goKigpfAcG1Qfw6KIwwwwy4s4UICashQFju3x/PqaFouju9VPWp6n6/rquv6jrn1Dl3PZemPzzneZ4TmYkkSVI/mlV3AZIkSRNlkJEkSX3LICNJkvqWQUaSJPUtg4wkSepbBhlJRMTp4zj21IjYaQzHrYqI902glgMi4g8RsecYjv1+RBy6mWOOjIh3tL3/TkTMH2dN20TEYETMG8/nNnPOrSPi/Ih4WKfOKc1EBhlpBoqI90XESyLi7yNiR+CqiPjHiDh2yHGPjIiXVb8PRMS2wD3ArWO4zNOBWaP98Y+IvSNiZdv7pcDngQ8Bfxjm+Biy6Vrgz5upYwmw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E232AMgW8fTzND4DfAo8CtqumjkvqMoOMpKFeS7nt0woi76LcMjm27Zh3ANcBP46IsyLiaUPDQ0RsD7yNsrjcszPzumrXHlQDcquxKM+h9K7sCbyCcrvpFcPUtTtwR2ZeOXRAbhRvoAyyvTozh3sW1EeBr1QB4+LMPDYzb6j27Qv874MwM/PdVT17A0dm5sVt13pe9Z2+U72fV237CeX2226UadiXRMSbI2L5MLVI6hDXkZE0rIjYidIrcUlmfm2Y/TtSpk5vT5kNdGFmfn8M5/0eZYDvCeOs54nA8sz87Aj751N6ky7MzA+M89zPAB6+uc9V3/nvq2nerZ6dFZSZT99pm8HUGmv0KcoYn+soz5f6GWW69ngfuilpBAYZSVMqIo6kPHjymrprkdT/DDKSJKlvOUZGkiT1LYOMJEnqWwYZSZLUtwwykiSpbxlkJElS3zLISJKkvmWQkSRJfev/B/F6BBF3zLCqAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 648x432 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "depth = np.arange(1,16)\n",
    "err = [] # 列表，error误差，可以使用准确率表示accurate；err = 1 - accurate\n",
    "for d in depth:\n",
    "    model = DecisionTreeClassifier(criterion='entropy',max_depth=d)\n",
    "    model.fit(X_train,y_train)\n",
    "    score = model.score(X_test,y_test)\n",
    "    err.append(1 - score)\n",
    "#     print('决策树深度是%d，错误率为%0.3f%%' % (d ,100 * (1 - score)))\n",
    "# 画图    \n",
    "plt.figure(figsize=(9,6))\n",
    "plt.rcParams['font.family'] = 'STKaiti'\n",
    "plt.plot(depth,err,'ro-')\n",
    "plt.xlabel('决策树深度',fontsize = 18)\n",
    "plt.ylabel('错误率',fontsize = 18)\n",
    "plt.title('筛选合适决策树深度')\n",
    "plt.grid()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "id": "18be46d3",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2022-06-27T14:01:58.150551Z",
     "start_time": "2022-06-27T14:01:58.016496Z"
    },
    "collapsed": true
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAjIAAAGHCAYAAACqI7gCAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/YYfK9AAAACXBIWXMAAAsTAAALEwEAmpwYAAAu1UlEQVR4nO3deZhcVZ3/8fc3GyGEPRAgBAKoLKJsUWBQCLgjCjOjPxUQ1FHcEJ2f4zKizjjj7ijuI1F0BsEBN2RGUMDRBlEGhQHF34Abgl0JS0jYkhAI5Pv749wei6aTdHVX1a3qfr+ep5+qunXr3m+dJ0l/cu4550ZmIkmS1I+m1F2AJEnSWBlkJElS3zLISJKkvmWQkSRJfcsgI0mS+pZBRhIR8Z0W9j0/IrYbxX6nRMT7x1DLgRFxc0Q8bhT7XhoRh29kn2Mi4j1Nry+IiJkt1rR5RAxExIxWPreRY86OiCsi4ontOqY0GRlkpEkoIt4fEa+OiFdGxLbArRHxuog4edh+T46I11bPZ0XEFsDDwL2jOM3zgSkb+uUfEXtHxKKm1/OAs4CPADePsH8M29QA7t9IHTsCd0XEOyPiycCTgEsj4sKRAllE/CAiNmvelpn3Aysy86Fh+74qIraPiIMi4rLqs/9R/dwYEUevr6jMXAn8LfCiiPhcRBy0ke8haQTT6i5AUndFxG6UX/5Tga8AfwX8AvhVZv5s2O43AG+sfrE/A9gZCOBVEfGtzFy2nnMcCfwO+Djw0Yh4W2auHWHX3wPHR8RNwIPA64DfZuaZ6yn/koj4j8z8TPV6LbB1RLwB+LfMvHtYHbOA/avv+3HgZcDRwHMz89PrOcfPMnNVREwHngLcmZm/A24aYd9fUYLR8dXPk4Al1fmeDlwz/AMR8RpKGJxfvX89cF9mXrueeiRtgD0y0uSzC/AZSm9GAudSAsULIuKFzTtm8VpgNbAP8EvgbuCrwIiXZ6pelbcA78rM5cA5wIi9H1UPx4cz8/Yq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U0zmIbGGn2aMsZnKeX+Uj+hTNdu9aabktbDICOpqyLiGMqNJwfrrkVS/zPISJKkvuUYGUmS1LcMMpIkqW8ZZCRJUt8yyEiSpL5lkJEkSX3LICNJkvqWQUaSJPWt/w/D3Uyxdwa3WwAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 648x432 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "depth = np.arange(1,16)\n",
    "acc = []\n",
    "for d in depth:\n",
    "    model = DecisionTreeClassifier(criterion='entropy',max_depth=d)\n",
    "    model.fit(X_train,y_train)\n",
    "    score = model.score(X_test,y_test)\n",
    "    acc.append(score)\n",
    "#     print('决策树深度是%d，错误率为%0.3f%%' % (d ,100 * (1 - score)))\n",
    "# 画图    \n",
    "plt.figure(figsize=(9,6))\n",
    "plt.rcParams['font.family'] = 'STKaiti'\n",
    "plt.plot(depth,acc,'ro-')\n",
    "plt.xlabel('决策树深度',fontsize = 18)\n",
    "plt.ylabel('准确率',fontsize = 18)\n",
    "plt.title('筛选合适决策树深度')\n",
    "plt.grid()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "id": "65f9bd15",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2022-06-27T14:02:45.357378Z",
     "start_time": "2022-06-27T14:02:45.335485Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([0.        , 0.01126989, 0.6394416 , 0.3492885 ])"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 决策树，进行构建时，信息熵、gini系数构建\n",
    "# 获取，不同属性的重要性【不同】\n",
    "# 0，删除，也不会有影响\n",
    "model.feature_importances_"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "0a6682e1",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.6"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {
    "height": "calc(100% - 180px)",
    "left": "10px",
    "top": "150px",
    "width": "284.444px"
   },
   "toc_section_display": true,
   "toc_window_display": true
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
